#include <iostream>
#include <vector>
#include <deque>
#include <array>
#include "traits.hpp"

template <typename T>
typename std::enable_if<impl::is_container<T>::value>::type foo(T const& arg)
{
    std::cout << "is container\n";
    for (auto const& i : arg)
    {
        std::cout << i << ",";
    }
    std::cout << '\n';
}

template <typename T>
typename std::enable_if<std::is_array<T>::value>::type foo(T const& arg)
{
    std::cout << "is array\n";
    typename std::remove_all_extents<T>::type const* ptr = &arg[0];
    while (*ptr)
    {
        std::cout << *ptr << ",";
        ++ptr;
    }
    std::cout << '\n';
}

class A
{
  public:
    A(){};
    int* begin();
    int* end();
    size_t size();
};

int main(int argc, char** argv)
{
    static_assert(impl::is_container<std::vector<int>>::value,
                  "vector<int> failed");
    // static_assert(impl::is_container<int>::value, "int failed");
    static_assert(impl::is_container<std::deque<int>>::value,
                  "deque<int> failed");
    // static_assert(impl::is_container<A>::value, "A is not container");
    std::vector<int> vi{1, 2, 3, 4, 5};
    std::deque<int> di{1, 2, 3, 4, 5};
    int arr[10]{1, 2, 3, 4, 5};
    foo(vi);
    foo(di);
    foo(arr);
    return 0;
}